import java.math.*;

public class AddGate implements Gate{

    int ID;
    int leftID, rightID;    
    int leftType, rightType;

    BigInteger share;

    public AddGate(int ID, Gate leftGate, Gate rightGate){
        this.ID = ID;
        
        int left = leftGate.getID();
        int right = rightGate.getID();
        if(leftGate instanceof InputGate){
            leftType = Utilities.INPUTGATE;
            leftID = left;
        }else if(leftGate instanceof ConstGate){
            leftType = Utilities.CONSTGATE;
            leftID = left;
        }else if(leftGate instanceof AddGate){
            leftType = Utilities.ADDGATE;
            leftID = left;
        }else{
            leftType = Utilities.MULTGATE;
            leftID = left;
        }
        
        if(rightGate instanceof InputGate){
            rightType = Utilities.INPUTGATE;
            rightID = right;
        }else if(rightGate instanceof ConstGate){
            rightType = Utilities.CONSTGATE;
            rightID = right;
        }else if(rightGate instanceof AddGate){
            rightType = Utilities.ADDGATE;
            rightID = right;
        }else{
            rightType = Utilities.MULTGATE;
            rightID = right;
        }        
    }

    public AddGate(int ID){
        this.ID = ID;
    }

    public BigInteger getShare(){
        return share;
    }

    public void setShare(BigInteger share){
        this.share = share;
    }

    public int getID(){
        return ID;
    }

    public AddGate copy(){
        AddGate copy = new AddGate(ID);
        copy.leftID = leftID;
        copy.rightID = rightID;
        copy.leftType = leftType;
        copy.rightType = rightType;
        if(share != null){
            copy.setShare(share);
        }
        return copy;
    }
}